Skip to content

Use the stdlib Hashtbl for the compiler's hash sets - #8787

Merged
cknitt merged 3 commits into
stdlib-hashtblfrom
stdlib-hashset
Oct 11, 2026
Merged

cknitt merged 3 commits into
stdlib-hashtblfrom
stdlib-hashset

Conversation

@cknitt

@cknitt cknitt commented Oct 10, 2026

Copy link
Copy Markdown
Member

Second of four PRs moving the compiler's own collections onto the OCaml standard library, stacked on #8786. This one covers hash sets.

Hash_set_ident, Hash_set_string and Used_attributes.Attribute_name_set are now unit tables from Hashtbl.Make, using the same equality and hash functions as before. Lam_module_ident.Hash_set is an alias of Lam_module_ident.Hash. Hash_set and Hash_set_gen are removed, together with their ounit tests.

  • Keep-first adds. Every add is guarded by mem, so the first key added is kept. This matters for Lam_module_ident: two module ids can be equal while carrying different ids, and the first one decides the name the import is bound to. Lam_module_ident.set_add does this for the module sets.
  • Deterministic import order. The hard dependencies were sorted by module name only, so ties fell back to hash-set order. Ties happen when the same module is imported both with and without default. They are now broken by kind and then default. The one change in the generated output is key_word_property.mjs. There the old order put default first for one module and last for another; now the plain import always comes first.

Output: byte-identical to #8786 on 627 of 628 files; the exception is key_word_property.res, described above.

Performance: neutral (CPU +0.2%, allocation −0.1% vs master). Earlier figures that suggested a speedup didn't reproduce.

🤖 Generated with Claude Code

cknitt and others added 2 commits October 10, 2026 18:50
Hash sets are unit Hashtbl.Make tables; adds keep the first key. Sort hard
dependencies by a total order so ties no longer depend on hash order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt added this pull request to stack #8788 October 10, 2026 18:50
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
@pkg-pr-new

pkg-pr-new Bot commented Oct 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8787

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8787

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8787

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8787

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8787

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8787

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8787

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8787

commit: 9b8ce57

@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.64%. Comparing base (ccb7c23) to head (9b8ce57).

Files with missing lines Patch % Lines
compiler/core/lam_module_ident.ml 75.00% 2 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           stdlib-hashtbl    #8787      +/-   ##
==================================================
- Coverage           80.66%   80.64%   -0.03%     
==================================================
  Files                 461      458       -3     
  Lines               62630    62523     -107     
==================================================
- Hits                50520    50420     -100     
+ Misses              12110    12103       -7     
Files with missing lines Coverage Δ
compiler/core/js_fold_basic.ml 100.00% <ø> (ø)
compiler/core/lam_check.ml 95.00% <100.00%> (ø)
compiler/core/lam_coercion.ml 97.50% <100.00%> (ø)
compiler/core/lam_compile_env.ml 84.44% <100.00%> (ø)
compiler/core/lam_compile_main.ml 89.87% <100.00%> (+0.16%) ⬆️
compiler/core/lam_dce.ml 92.10% <ø> (ø)
compiler/ext/hash_set_ident.ml 100.00% <ø> (ø)
compiler/ml/used_attributes.ml 100.00% <100.00%> (ø)
tests/ounit_tests/ounit_tests_main.ml 100.00% <ø> (ø)
compiler/core/lam_module_ident.ml 90.90% <75.00%> (-9.10%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cknitt
cknitt marked this pull request as ready for review October 11, 2026 05:28
@cknitt

cknitt commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 9b8ce57768

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T05:30:56.687735Z 9b8ce57 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cknitt
cknitt requested a review from cristianoc October 11, 2026 05:33
@cknitt
cknitt merged commit a95e4f3 into master Oct 11, 2026
24 checks passed
@cknitt
cknitt deleted the stdlib-hashset branch October 11, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants